package io.afu.baseframework.controller;

import io.afu.baseframework.annotations.BSLog;
import io.afu.baseframework.annotations.MustUpper;
import io.afu.baseframework.dto.req.TestReq;
import io.afu.baseframework.dto.resp.BaseResp;
import io.afu.common.exception.BaseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletRequest;

/**
 * @author RffanLAB.方露宇
 * @version 0.1
 */
@RestController
@RequestMapping("/basetest")
public class TestController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @PostMapping("/testvalidated")
    @BSLog
    @MustUpper
    public BaseResp testValidated(@RequestBody @Validated TestReq testReq) {
        return BaseResp.success(testReq);
    }


    @PostMapping("/test401")
    @BSLog
    @ResponseStatus(HttpStatus.UNAUTHORIZED)
    public BaseResp test401(
    ) {

        logger.info("请求了401点接口");
        return BaseResp.success();
    }

    @PostMapping("/testLogbody")
    @BSLog
    public BaseResp testLogBody(
            @RequestBody TestReq testReq
    ) throws BaseException {
        throw new BaseException("测试异常");
//        return BaseResp.success();
    }



}
